

Page({
  data: {
    //头部导航栏高度(因为导航栏和二级菜单用的是fixed定位)
    wxBaiHeight:Number(wx.getStorageSync('wxBarHeight')),
    //二级菜单高度（因为导航栏和二级菜单用的是fixed定位）
    submenu:Number(wx.getStorageSync('submenu')),

    username: '',
    password: '',
    mgs: "水族箱信息",
    select: [0, 0, 0, 0],
    userAquariumList: [],
    // 选中的组件的下标，从1开始
    selectIndex:Number,

    //水质信息选择时间后跳转到index,用这个变量接收传递的时间
    time:Number
  },
  onLoad: function (options) {
       
    wx.showLoading({
      title: '加载中...',
    })
    this.setData({
      username: wx.getStorageSync('username'),
      password: wx.getStorageSync('password'),
      userAquariumList: wx.getStorageSync('userAquariumList')
    })
    if (!this.data.username) {
      wx.hideTabBar({
        animation: false,
      })
    }
    if (this.data.username) {
      wx.showTabBar({
        animation: false,
      })
    }

    //页面跳转时，如果有路由参数，则跳转到该路由
    if (options.selectIndex) {
      switch(Number(options.selectIndex)){
        case 1:
          this.chance1()
          break;
        case 2:
          this.chance2()
          break;
        case 3:
          this.chance3()
          break;
        case 4:
          this.chance4()
          break;
      }
    }else{
      this.chance1()
    }

    if(wx.getStorageSync('status') != 2){
        wx.removeTabBarBadge({
          index: 2,
        })
    }

   
   
    wx.hideLoading({
      success: (res) => { },
    })
  },

  //开启下拉刷新
  onPullDownRefresh: function () {

  },

  changeData:function(selectIndex){
    this.onLoad(selectIndex)
  },

  register() {
    wx.navigateTo({
      // url: '/pages/register/register'
      // 使用分包路径
      url: '../../pkgA/register/register'
    })
  },
  login() {
    wx.navigateTo({
      // url: '/pages/login/login'
      //使用分包路径
      url: '../../pkgA/login/login'
    })
  },
  chance1() {
    this.setData({
      select: [1, 0, 0, 0],
      mgs: "水族箱信息",
      selectIndex:1
    })
  },
  chance2() {
    this.setData({
      select: [0, 1, 0, 0],
      mgs: "鱼类信息",
      selectIndex:2
    })
  },
  chance3() {
    this.setData({
      select: [0, 0, 1, 0],
      mgs: "水质信息",
      selectIndex:3
    })
    
  },
  chance4() {
    this.setData({
      select: [0, 0, 0, 1],
      mgs: "水族箱管理",
      selectIndex:4
    })
  },


  showNav() {
    // console.log(wx.getStorageSync('userAquariumList'))
    return wx.getStorageSync('userAquariumList')
  },

})
